package com.lggry;


import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class UserServiceAiTest {

    private UserService userService;

    @BeforeEach
    public void setUp() {
        userService = new UserService();
    }

    @Test
    public void getGender_NullInput_ThrowsException() {
        Assertions.assertThrows(IllegalArgumentException.class, () -> {
            userService.getGender(null);
        });
    }

    @Test
    public void getGender_InvalidLength_ThrowsException() {
        Assertions.assertThrows(IllegalArgumentException.class, () -> {
            userService.getGender("12345678901234567"); // 17位
        });
    }

    @Test
    public void getGender_ValidInputEven17thDigit_ReturnsFemale() {
        String idCard = "152601199406211638"; // 第17位是8，偶数
        String gender = userService.getGender(idCard);
        Assertions.assertEquals("男", gender);
    }

    @Test
    public void getGender_ValidInputOdd17thDigit_ReturnsMale() {
        String idCard = "152601199406211639"; // 第17位是9，奇数
        String gender = userService.getGender(idCard);
        Assertions.assertEquals("男", gender);
    }
}